/*
Copyright (C) 2009  Raymond Jeon
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


#ifndef __GL_LIB_MEMORY_H__
#define __GL_LIB_MEMORY_H__


#include <string.h>
#include <stdlib.h>


#ifdef _DEBUG //		

#define GlMalloc(size)		GlMpMalloc	(size,		#size,	__FILE__, __LINE__) 
#define GlCalloc(num, size)	GlMpCalloc	(num, size, #num,	__FILE__, __LINE__)
#define GlRealloc(m, size)	GlMpRealloc	(m, size,	#m,		__FILE__, __LINE__)
#define GlStrDup(s)			GlMpStrDup	(s,			#s,		__FILE__, __LINE__)
#define GlStrnDup(s, size)	GlMpStrnDup	(s, size,	#s,		__FILE__, __LINE__)
#define GlFree(m)			GlMpFree	(m,			#m,		__FILE__, __LINE__)

#else		

#define GlMalloc(size)		malloc	(size) 
#define GlCalloc(num, size)	calloc	(num, size)
#define GlRealloc(m, size)	realloc	(m, size)
#define GlStrDup(s)			strdup	(s)
#define GlStrnDup(s, size)	strndup	(s, size)
#define GlFree(m)			free	(m)

#endif		




void	GlThreadPoolInit();
void*	GlMpMalloc	(size_t size,				char *szExp, char *szFile, int iLine);
void*	GlMpCalloc	(size_t num, size_t size,	char *szExp, char *szFile, int iLine);
void*	GlMpRealloc	(void *m, size_t size,		char *szExp, char *szFile, int iLine);
char*	GlMpStrDup	(char *s,					char *szExp, char *szFile, int iLine);
char*	GlMpStrnDup	(char *s, size_t size,		char *szExp, char *szFile, int iLine);
void	GlMpFree	(void *m,					char *szExp, char *szFile, int iLine);



#undef FALSE
#undef TRUE
#undef NULL
#define FALSE   0
#define TRUE    1
#define NULL    0


#endif // __GL_LIB_MEMORY_H__